<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="generator" content="VuePress 2.0.0-beta.66">
    <style>
      :root {
        --c-bg: #fff;
      }
      html.dark {
        --c-bg: #22272e;
      }
      html, body {
        background-color: var(--c-bg);
      }
    </style>
    <script>
      const userMode = localStorage.getItem('vuepress-color-scheme');
			const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
			if (userMode === 'dark' || (userMode !== 'light' && systemDarkMode)) {
				document.documentElement.classList.toggle('dark', true);
			}
    </script>
    <title>CURD命令大全 | EasyAdmin8</title><meta name="description" content="基于ThinkPHP8.0搭建的后台管理系统EasyAdmin8,PHP 最低版本要求不低于 8.0、Layui v2.8.x.">
    <link rel="preload" href="/home/assets/style-4fc1705f.css" as="style"><link rel="stylesheet" href="/home/assets/style-4fc1705f.css">
    <link rel="modulepreload" href="/home/assets/app-db7ad3fc.js"><link rel="modulepreload" href="/home/assets/CURD.html-80c057bf.js"><link rel="modulepreload" href="/home/assets/CURD.html-1be6a1bd.js"><link rel="prefetch" href="/home/assets/index.html-85ba42b5.js" as="script"><link rel="prefetch" href="/home/assets/main.html-cb67d39a.js" as="script"><link rel="prefetch" href="/home/assets/404.html-f9875e7b.js" as="script"><link rel="prefetch" href="/home/assets/index.html-b474e83e.js" as="script"><link rel="prefetch" href="/home/assets/main.html-6a1f0cc9.js" as="script"><link rel="prefetch" href="/home/assets/404.html-2f962f24.js" as="script">
  </head>
  <body>
    <div id="app"><!--[--><div class="theme-container"><!--[--><header class="navbar"><div class="toggle-sidebar-button" title="toggle sidebar" aria-expanded="false" role="button" tabindex="0"><div class="icon" aria-hidden="true"><span></span><span></span><span></span></div></div><span><a href="/home/" class=""><!----><span class="site-name">EasyAdmin8</span></a></span><div class="navbar-items-wrapper" style=""><!--[--><!--]--><nav class="navbar-items can-hide"><!--[--><div class="navbar-item"><a href="/home/" class="" aria-label="首页"><!--[--><!--]--> 首页 <!--[--><!--]--></a></div><div class="navbar-item"><a class="external-link" href="http://easyadmin8.wolfcode.top/admin" rel="noopener noreferrer" target="_blank" aria-label="后台演示"><!--[--><!--]--> 后台演示 <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><div class="navbar-item"><a class="external-link" href="https://github.com/wolf-leo/easyAdmin8" rel="noopener noreferrer" target="_blank" aria-label="GitHub"><!--[--><!--]--> GitHub <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><div class="navbar-item"><a class="external-link" href="https://gitee.com/wolf18/easyAdmin8" rel="noopener noreferrer" target="_blank" aria-label="Gitee"><!--[--><!--]--> Gitee <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><!--]--></nav><!--[--><!--]--><button class="toggle-color-mode-button" title="toggle color mode"><svg style="" class="icon" focusable="false" viewBox="0 0 32 32"><path d="M16 12.005a4 4 0 1 1-4 4a4.005 4.005 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6z" fill="currentColor"></path><path d="M5.394 6.813l1.414-1.415l3.506 3.506L8.9 10.318z" fill="currentColor"></path><path d="M2 15.005h5v2H2z" fill="currentColor"></path><path d="M5.394 25.197L8.9 21.691l1.414 1.415l-3.506 3.505z" fill="currentColor"></path><path d="M15 25.005h2v5h-2z" fill="currentColor"></path><path d="M21.687 23.106l1.414-1.415l3.506 3.506l-1.414 1.414z" fill="currentColor"></path><path d="M25 15.005h5v2h-5z" fill="currentColor"></path><path d="M21.687 8.904l3.506-3.506l1.414 1.415l-3.506 3.505z" fill="currentColor"></path><path d="M15 2.005h2v5h-2z" fill="currentColor"></path></svg><svg style="display:none;" class="icon" focusable="false" viewBox="0 0 32 32"><path d="M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z" fill="currentColor"></path></svg></button><!----></div></header><!--]--><div class="sidebar-mask"></div><!--[--><aside class="sidebar"><nav class="navbar-items"><!--[--><div class="navbar-item"><a href="/home/" class="" aria-label="首页"><!--[--><!--]--> 首页 <!--[--><!--]--></a></div><div class="navbar-item"><a class="external-link" href="http://easyadmin8.wolfcode.top/admin" rel="noopener noreferrer" target="_blank" aria-label="后台演示"><!--[--><!--]--> 后台演示 <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><div class="navbar-item"><a class="external-link" href="https://github.com/wolf-leo/easyAdmin8" rel="noopener noreferrer" target="_blank" aria-label="GitHub"><!--[--><!--]--> GitHub <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><div class="navbar-item"><a class="external-link" href="https://gitee.com/wolf18/easyAdmin8" rel="noopener noreferrer" target="_blank" aria-label="Gitee"><!--[--><!--]--> Gitee <span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><!--]--></nav><!--[--><!--]--><ul class="sidebar-items"><!--[--><li><p tabindex="0" class="sidebar-item sidebar-heading">CURD命令大全 <!----></p><!----></li><!--]--></ul><!--[--><!--]--></aside><!--]--><!--[--><main class="page"><!--[--><!--]--><div class="theme-default-content"><!--[--><!--]--><div><h1 id="curd命令大全" tabindex="-1"><a class="header-anchor" href="#curd命令大全" aria-hidden="true">#</a> CURD命令大全</h1><p><code>EasyAdmin8</code>框架以内置快速生成CURD的命令, 包括控制器、视图、模型、JS文件。能够使开发者效率得到进一步提升。</p><h1 id="常用命令" tabindex="-1"><a class="header-anchor" href="#常用命令" aria-hidden="true">#</a> 常用命令</h1><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token comment"># 生成ea8_test_goods表的CURD</span>
php think curd <span class="token parameter variable">-t</span> test_goods

<span class="token comment"># 生成ea8_test_goods表的CURD, 文件冲突时强制覆盖</span>
php think curd <span class="token parameter variable">-t</span> test_goods <span class="token parameter variable">-f</span> <span class="token number">1</span>

<span class="token comment"># 删除ea8_test_goods表的CURD</span>
php think curd <span class="token parameter variable">-t</span> test_goods <span class="token parameter variable">-d</span> <span class="token number">1</span>

<span class="token comment"># 生成ea8_test_goods表的CURD, 控制器在目录demo下的Goods.php文件</span>
php think curd <span class="token parameter variable">-t</span> test_goods <span class="token parameter variable">-c</span> demo/Goods

<span class="token comment"># 生成ea8_test_goods表的CURD, 模型在目录demo下的Goods.php文件</span>
php think curd <span class="token parameter variable">-t</span> test_goods <span class="token parameter variable">-m</span> demo/Goods

<span class="token comment"># 生成ea8_test_goods表的CURD, 并关联ea8_test_cate表, 并设置外键为cate_id</span>
php think curd <span class="token parameter variable">-t</span> test_goods <span class="token parameter variable">-r</span> test_cate <span class="token parameter variable">--foreignKey</span><span class="token operator">=</span>cate_id <span class="token parameter variable">--primaryKey</span><span class="token operator">=</span>id

<span class="token comment"># 生成ea8_test_goods表的CURD, 并关联ea8_test_cate表, 并设置只显示title,image两个字段</span>
php think curd <span class="token parameter variable">-t</span> test_goods <span class="token parameter variable">-r</span> test_cate <span class="token parameter variable">--foreignKey</span><span class="token operator">=</span>cate_id <span class="token parameter variable">--relationOnlyFileds</span><span class="token operator">=</span>title,image

<span class="token comment"># 生成ea8_test_goods表的CURD, 并关联ea8_test_cate表, 并设置主表外键cate_id在表单的下拉选择显示的关联表的title字段</span>
php think curd <span class="token parameter variable">-t</span> test_goods <span class="token parameter variable">-r</span> test_cate <span class="token parameter variable">--foreignKey</span><span class="token operator">=</span>cate_id <span class="token parameter variable">--relationBindSelect</span><span class="token operator">=</span>title

<span class="token comment"># 生成ea8_test_goods表的CURD, 并设置logo字段后缀为单图片</span>
php think curd <span class="token parameter variable">-t</span> test_goods <span class="token parameter variable">--imageFieldSuffix</span><span class="token operator">=</span>logo

<span class="token comment"># 生成ea8_test_goods表的CURD, 并设置忽略remark, stock字段</span>
php think curd <span class="token parameter variable">-t</span> test_goods <span class="token parameter variable">--ignoreFields</span><span class="token operator">=</span>remark <span class="token parameter variable">--ignoreFields</span><span class="token operator">=</span>stock
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h1 id="参数介绍" tabindex="-1"><a class="header-anchor" href="#参数介绍" aria-hidden="true">#</a> 参数介绍</h1><table><thead><tr><th>短参</th><th>长参</th><th>说明</th></tr></thead><tbody><tr><td>-t</td><td>--table=VALUE</td><td>主表名</td></tr><tr><td>-c</td><td>--controllerFilename=VALUE</td><td>控制器文件名</td></tr><tr><td>-m</td><td>--modelFilename=VALUE</td><td>主表模型文件名</td></tr><tr><td>-f</td><td>--force=VALUE</td><td>强制覆盖模式</td></tr><tr><td>-d</td><td>--delete=VALUE</td><td>删除模式</td></tr><tr><td></td><td>--checkboxFieldSuffix=VALUE</td><td>复选框字段后缀</td></tr><tr><td></td><td>--radioFieldSuffix=VALUE</td><td>单选框字段后缀</td></tr><tr><td></td><td>--imageFieldSuffix=VALUE</td><td>单图片字段后缀</td></tr><tr><td></td><td>--imagesFieldSuffix=VALUE</td><td>多图片字段后缀</td></tr><tr><td></td><td>--fileFieldSuffix=VALUE</td><td>单文件字段后缀</td></tr><tr><td></td><td>--filesFieldSuffix=VALUE</td><td>多文件字段后缀</td></tr><tr><td></td><td>--dateFieldSuffix=VALUE</td><td>时间字段后缀</td></tr><tr><td></td><td>--switchFields=VALUE</td><td>开关的字段</td></tr><tr><td></td><td>--selectFileds=VALUE</td><td>下拉的字段</td></tr><tr><td></td><td>--editorFields=VALUE</td><td>富文本的字段</td></tr><tr><td></td><td>--sortFields=VALUE</td><td>排序的字段</td></tr><tr><td></td><td>--ignoreFields=VALUE</td><td>忽略的字段</td></tr><tr><td>-r</td><td>--relationTable=VALUE</td><td>关联表名</td></tr><tr><td></td><td>--foreignKey=VALUE</td><td>关联外键</td></tr><tr><td></td><td>--primaryKey=VALUE</td><td>关联主键</td></tr><tr><td></td><td>--relationOnlyFileds=VALUE</td><td>关联模型中只显示的字段</td></tr><tr><td></td><td>--relationBindSelect=VALUE</td><td>关联模型中的字段用于主表外键的表单下拉选择</td></tr><tr><td></td><td>--relationModelFilename=VALUE</td><td>关联模型文件名</td></tr></tbody></table></div><!--[--><!--]--></div><footer class="page-meta"><!----><!----><!----></footer><!----><!--[--><!--]--></main><!--]--></div><!----><!--]--></div>
    <script type="module" src="/home/assets/app-db7ad3fc.js" defer></script>
  </body>
</html>
